package gui.newQuiz;

import gui.GUIMain;

import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import quiz.SimpleQuiz;

public class NewQuiz extends JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1754930057657077232L;
	JButton addQuestion;
	JLabel labelQuizName;
	JTextField textQuizName;
	JButton ok;
	NewQuizButtonListener listener;
	SimpleQuiz quiz;
	GUIMain GUIMain;
	
	public NewQuiz(GUIMain GUIMain) {
		this.GUIMain = GUIMain;
		initializeVariables();
		setupWindows();
		connectComponents();
		addActionListeners();
	}
	private void initializeVariables() {
		addQuestion = new JButton("Add questions");
		labelQuizName = new JLabel("Quiznavn:");
		textQuizName = new JTextField("");
		ok = new JButton("Ok");
		listener = new NewQuizButtonListener(this);
		quiz = new SimpleQuiz();
	}
	private void setupWindows() {
		getContentPane().setLayout(new GridLayout(2,2));
		setPreferredSize(new Dimension(400,400));
		getContentPane().setVisible(true);
		setVisible(true);
		pack();
	}
	private void connectComponents() {
		getContentPane().add(labelQuizName);
		getContentPane().add(textQuizName);
		getContentPane().add(addQuestion);
		getContentPane().add(ok);
	}
	private void addActionListeners() {
		addQuestion.addActionListener(listener);
		ok.addActionListener(listener);
	}
}
